import http from '@/utils/http'

/**
 * 获取分类列表
 */
export const getCategoryList = (params = {}) => {
  return http.get('/goods/categories', {
    page: params.page || 1,
    page_size: params.page_size || 10,
    parent_id: params.parent_id || 0, // 0表示获取顶级分类
    ...params
  })
}

/**
 * 获取分类详情
 */
export const getCategoryDetail = (id) => {
  return http.get(`/goods/categories/${id}`)
}

/**
 * 获取子分类
 */
export const getSubCategories = (parentId, params = {}) => {
  return http.get('/goods/categories', {
    parent_id: parentId,
    page: params.page || 1,
    page_size: params.page_size || 20,
    ...params
  })
} 